package com.shanxia.im.sdk.client.model;

import com.shanxia.codec.ProtocolDataBase;

import java.io.Serializable;

/**
 * 消息对象
 */
public class Message implements Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * 消息类型，用户自定义消息类别
	 */
	private long id;

	/**
	 * 消息类型，用户自定义消息类别
	 */
	private String action;
	/**
	 * 消息标题
	 */
	private String title;

	/**
	 * 消息类容
	 */
	private ProtocolDataBase protocolDataBase;

	/**
	 * 消息发送者账号
	 */
	private String sender;
	/**
	 * 消息发送者接收者
	 */
	private String receiver;

	private long timestamp;

	public Message() {
		timestamp = System.currentTimeMillis();
	}

	public ProtocolDataBase getProtocolDataBase() {
		return protocolDataBase;
	}

	public void setProtocolDataBase(ProtocolDataBase protocolDataBase) {
		this.protocolDataBase = protocolDataBase;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public long getTimestamp() {
		return timestamp;
	}

	public void setTimestamp(long timestamp) {
		this.timestamp = timestamp;
	}

	public String getAction() {
		return action;
	}

	public void setAction(String action) {
		this.action = action;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}


	public String getSender() {
		return sender;
	}

	public void setSender(String sender) {
		this.sender = sender;
	}

	public String getReceiver() {
		return receiver;
	}

	public void setReceiver(String receiver) {
		this.receiver = receiver;
	}


	@Override
	public String toString() {

		StringBuffer buffer = new StringBuffer();
		buffer.append("#Message#").append("\n");
		buffer.append("id:").append(id).append("\n");
		buffer.append("action:").append(action).append("\n");
		buffer.append("title:").append(title).append("\n");
		//buffer.append("content:").append(content).append("\n");
		//buffer.append("extra:").append(extra).append("\n");
		buffer.append("sender:").append(sender).append("\n");
		buffer.append("receiver:").append(receiver).append("\n");
		//buffer.append("format:").append(format).append("\n");
		buffer.append("timestamp:").append(timestamp);
		return buffer.toString();
	}


	public boolean isNotEmpty(String txt) {
		return txt != null && txt.trim().length() != 0;
	}

}
